home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00107_Script_CHECK DATABASE - INDEX < prev    next >
Text File  |  1996-03-28  |  3KB  |  75 lines

  1. -- --------------------------------------------------------------
  2. -- Handler checkIndex checks all the search results in the index
  3. -- fields and puts the errors in the appropriate "Index Errors"
  4. -- field ("A INDEX ERRORS", "B INDEX ERRORS", ...)
  5.  
  6. on checkIndex firstCast, lastCast
  7.   initalizeEquivalentTerms
  8.   emptyIndexErrorFields
  9.   
  10.   set oldIndexLetter = char 1 of the name of cast firstCast
  11.   set errorFieldName = oldIndexLetter && "INDEX ERRORS"
  12.   
  13.   -- go through the index casts one by one
  14.   repeat with curIndex = firstCast to lastCast
  15.     set castName = the name of cast curIndex
  16.     put "checking" && castName
  17.     
  18.     set indexLetter = char 1 of castName
  19.     if (indexLetter <> oldIndexLetter) then  -- new letter
  20.       set errorFieldName = indexLetter && "INDEX ERRORS"
  21.       set oldIndexLetter = indexLetter
  22.     end if
  23.     
  24.     set indexText = field curIndex
  25.     set numLines = the number of lines in indexText
  26.     
  27.     -- go through the lines one by one
  28.     repeat with curLine = 1 to numLines
  29.       set lineText = line curLine of indexText
  30.       
  31.       if (char 1 of lineText = "*") then -- new entry
  32.         set curEntry = char 2 to length(lineText) of lineText
  33.         put "checking entry" && curEntry
  34.       else
  35.         set searchResult = the number of cast (lineText && "TEXT1")
  36.         
  37.         if (searchResult = -1) then
  38.           -- check if an equivalent term exists
  39.           set equivTerm = getEquivalentTerm(searchResult)
  40.           if (equivTerm = -1) then
  41.             -- index error
  42.             put curEntry & ":" & lineText & RETURN after field errorFieldName
  43.           end if -- equivTerm = -1
  44.         end if -- searchResult = -1
  45.       end if -- new Entry
  46.     end repeat -- going through the lines
  47.     put "finished checking" && castName
  48.   end repeat -- going through the casts
  49. end
  50.  
  51. -- --------------------------------------------------------------
  52. -- Handler emptyIndexErrorFields resets the index error fields for
  53. -- the new generation of index errors.
  54.  
  55. on emptyIndexErrorFields
  56.   repeat with indexLetter = 65 to 90 -- "A" to "Z"
  57.     set indexFieldName = numToChar(indexLetter) && "INDEX ERRORS"
  58.     put EMPTY into field indexFieldName
  59.   end repeat
  60. end
  61.  
  62. on checkIndexForDuplicates firstCast, lastCast
  63.    put empty into field "indexEntries"
  64.   repeat with curIndex = firstCast to lastCast
  65.     set curIndexEntries = field curIndex
  66.     set numLines = the number of lines in curIndexEntries
  67.     repeat with curLine = 1 to numLines
  68.       if (char 1 of line curLine of curIndexEntries = "*") then
  69.         put line curline of curIndexEntries
  70.         put line curLine of curIndexEntries & RETURN after field "indexEntries"
  71.       end if
  72.     end repeat
  73.   end repeat
  74. end
  75.